package com.sanjiahantang.youjiarole.module.me.require.models.impl;

import android.content.Context;

import com.sanjiahantang.youjiarole.base.BaseBean;
import com.sanjiahantang.youjiarole.base.CallBack;
import com.sanjiahantang.youjiarole.config.ConfigValue;
import com.sanjiahantang.youjiarole.http.BaseDelegate;
import com.sanjiahantang.youjiarole.http.OkHttpClientManager;
import com.sanjiahantang.youjiarole.module.common.beans.StringBean;
import com.sanjiahantang.youjiarole.module.me.require.beans.RequireDetailInitResponseBean;
import com.sanjiahantang.youjiarole.module.me.require.beans.RequireListBean;
import com.sanjiahantang.youjiarole.module.me.require.models.IRequireModel;
import com.squareup.okhttp.Request;

import java.util.Map;

/**
 * Created by zy on 2017/10/24.
 */

public class RequireModel implements IRequireModel {
    @Override
    public void loadRequireList(final Context context, Map<String, Object> param, final CallBack<RequireListBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/phone/require/searchUserRequireInfoPhone",
                param,new BaseDelegate.ResultCallback<RequireListBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(RequireListBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void indexUserRequireInfoForRole(final Context context, Map<String, String> param, final CallBack<RequireDetailInitResponseBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/phone/role/indexUserRequireInfoForRole",
                param,new BaseDelegate.ResultCallback<RequireDetailInitResponseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(RequireDetailInitResponseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void fastBindUserCustomer(final Context context, Map<String, String> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/phone/role/fastBindUserCustomer",
                param,new BaseDelegate.ResultCallback<BaseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void updateRequireDesign(final Context context, Map<String, String> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/phone/role/updateRequireDesign",
                param,new BaseDelegate.ResultCallback<BaseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void saveBidRequireInfoForRole(final Context context, Map<String, String> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/phone/customerRequireBid/saveBidRequireInfoForRole",
                param,new BaseDelegate.ResultCallback<BaseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void findBidRequireInfoForRole(final Context context, Map<String, String> param, final CallBack<StringBean> callBack) {
        OkHttpClientManager.postAsyn(context, ConfigValue.API_URL + "/user/phone/customerRequireBid/findBidRequireInfoForRole",
                param,new BaseDelegate.ResultCallback<StringBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(StringBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }

    @Override
    public void addRequireSubcontractInfo(final Context context, Map<String, String> param, final CallBack<BaseBean> callBack) {
        OkHttpClientManager.postJson(context, ConfigValue.API_URL + "/user/phone/require/addRequireSubcontractInfo",
                param,new BaseDelegate.ResultCallback<BaseBean>() {

                    @Override
                    public void onError(Request request, Object tag, Exception e) {
                        callBack.onFailure(e.getMessage());
                    }

                    @Override
                    public void onResponse(BaseBean response, Object tag) {
                        callBack.onSuccess(response,context, tag);
                    }
                });
    }
}
